package com.henu.engineer.dao.mapper.cultivatingproject

import com.henu.engineer.dao.entity.cultivatingproject.CultivatingGoal
import org.apache.ibatis.annotations.Mapper
import org.springframework.stereotype.Repository
import java.time.LocalDate

/**
 * @author noexcept
 * @date 2021/7/26 13:59
 */
@Mapper
@Repository
interface CultivatingGoalXmlMapper {
    fun insertCultivatingGoal(content: String, specialization: String, version: LocalDate): Boolean

    fun deleteCultivatingGoal(id: Int): Boolean

    fun updateContentById(id: Int, content: String): Boolean

    fun updateById(goal: CultivatingGoal): Boolean

    fun selectCultivatingGoalById(id: String): CultivatingGoal

    /**
     * 查询毕业要求表中最新的版本是那个版本
     */
    fun selectLatestVersionInfoBySpec(specialization: String): LocalDate?

    /**
     *   SELECT id, content, specialization, version
     *   FROM cultivating_goal
     *   WHERE YEAR(version) <= #{version} order by YEAR(version) desc
     */
    fun selectCultivatingGoalByVersion(version: Int): List<CultivatingGoal>

    /**
     *
     */
    fun selectCultivatingGoalBySpec(specialization: String): List<CultivatingGoal>

    /**
     *   SELECT id, content, specialization, version
     *   FROM cultivating_goal
     *   WHERE specialization = #{spec}
     *   AND YEAR(version) <= #{version}
     */
    fun selectCultivatingGoalBySpecAndVersion(spec: String, version: LocalDate): List<CultivatingGoal>
}